package com.bcu.calculus.controller;


import com.bcu.calculus.entity.Message;
import com.bcu.calculus.entity.Unpass;
import com.bcu.calculus.service.UnpassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


@Api(tags = "06  不通过理由模块")
@RestController
@RequestMapping("/api/Unpass")
public class UnpassController {

    @Resource
    private UnpassService unpassService;


    @ApiOperation(value = "添加不通过信息")
    @PostMapping(value = "/add")
    public Message<?> addUnpadd(Unpass unpass){
        return unpassService.addUnpass(unpass);
    }

    @ApiOperation(value = "删除不通过信息")
    @DeleteMapping(value = "/del")
    public Message<?> delUnpass(Integer unpassId){
        return unpassService.delUnpss(unpassId);
    }

    @ApiOperation(value = "修改不通过信息")
    @PutMapping(value = "/update")
    public Message<?> updateUnpass(Unpass unpass){
        return unpassService.updateUnpass(unpass);
    }

    @ApiOperation(value = "查找所有不通过信息")
    @GetMapping(value = "/getAll")
    public Message<List<Unpass>> findAll(){
        return unpassService.selectAll();
    }


    @ApiOperation(value = "根据actId查不通过信息")
    @GetMapping(value = "/getByActId")
    public Message<Unpass> findOneByActId(Integer actId){
        return unpassService.selectOneByActId(actId);
    }

    //可能会需要增加的接口，需要连三张表
//    @ApiOperation(value = "根据sendId查不通过信息")
//    @GetMapping(value = "/getBySendId")
//    public Message<Unpass> findOneBySendId(Integer actId){
//        return unpassService.selectOneBySendId(sendId);
//    }

    @ApiOperation(value = "根据主键查不通过信息")
    @GetMapping(value = "/getByPK")
    public Message<Unpass> findOneByPK(Integer unpassId){
        return unpassService.selectOneByPrimaryKey(unpassId);
    }

    @ApiOperation(value = "查询所有路由错误的信息(该接口由于逻辑修改现在不可用)")
    @GetMapping(value = "/findAllRouterErrorInfo")
    public Message<?> findAllRouterErrorInfo(String unPassInfo,String SemId){
        //return unpassService.findAllRouterErrorInfo(unPassInfo,SemId);
        return null;
    }
}
